package net.arvin.utils;

import android.content.Context;
import android.preference.PreferenceManager;

public class PreferenceUtils {
	public static final String IsFirstUsed = "is_first_used";
	public static final String IsBindCard = "is_bind_card";
	public static final String Token = "token";
	public static final String User = "user";
	public static final String Card = "card";
	public static final String Cards = "cards";
	public static final String Phonenumber = "phonenumber";
	public static final String TransfersBill = "transfersBill";
	public static final String AvatarPath = "avatarpath";
	public static final String BillsJSON = "billsjson";

	public static void modifyStringValueInPreferences(final String key,
			final String value, final Context context) {
		PreferenceManager.getDefaultSharedPreferences(context).edit()
				.putString(key, value).commit();
	}

	public static void modifyIntValueInPreferences(final String key,
			final int value, final Context context) {
		PreferenceManager.getDefaultSharedPreferences(context).edit()
				.putInt(key, value).commit();
	}

	public static void modifyBooleanValueInPreferences(final String key,
			final boolean value, final Context context) {
		PreferenceManager.getDefaultSharedPreferences(context).edit()
				.putBoolean(key, value).commit();
	}

	public static void modifyFloatValueInPreferences(final String key,
			final float value, final Context context) {
		PreferenceManager.getDefaultSharedPreferences(context).edit()
				.putFloat(key, value).commit();
	}

	public static boolean getPreferIsFirstUsed(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getBoolean(IsFirstUsed, true);
	}

	public static String getPreferToken(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(Token, null);
	}

	public static String getPreferUserJson(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(User, null);
	}

	public static String getPreferBillsJson(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(BillsJSON, null);
	}

	public static String getPreferCards(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(Cards, null);
	}

	public static String getPreferCardJson(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(Card, null);
	}

	public static String getPreferTransfersBillJson(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(TransfersBill, null);
	}

	public static String getPreferPhonenumber(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(Phonenumber, null);
	}

	public static String getPreferAvatarPath(final Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context)
				.getString(AvatarPath, null);
	}

	public static void clearData(final Context context) {
		PreferenceManager.getDefaultSharedPreferences(context).edit().clear()
				.commit();
	}

}
